softdeclare.htmlHTMLudog5òπùΔ§πùΔ§ÅÅ+Å Monkeybread Realbasic plugin - Documentation - SoftDeclare

MBS Plugin Documentation

This is the documentation for the Realbasic Plugins from Monkeybreadsoftware.de. You find these plugins and the newest version of this document at http://www.monkeybreadsoftware.de/realbasic inside the plugins section.

This help was last updated on Freitag, 6. September 2002 and covers 2136 items: 126 classes, 2 controls and 583 global functions.

The list of the themes Global methods by category Global methods by name The list of the classes The list of the controls

class SoftDeclare

class, SoftDeclare Fr, 9. Aug 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: A way to do soft linking to libraries.
Notes:
You can make a declare like this:

Declare Function SpeakString lib "SpeechLib" (SpeakString as pstring) as Integer

But what if the SpeechLib is not installed?
Simple, but your application won't even launch on this machine.
Now you can of course use this MBS Plugin using the Speech functions, which are all week linked.
But you can also use this class to weak link to the Speech library like this:

dim b as boolean, m,p as memoryblock, c as softDeclare

c=new softDeclare
p=newmemoryBlock(256) // make the string for the first parameter
p.pstring(0)="Hello World!"

m=newmemoryBlock(4) // make the memoryblock for the parameters
m.long(0)=p.Address(0) // set the first parameter to the address of the string buffer

if c.loadlibary("SpeechLib") then // Load librarys
if c.loadfunction("SpeakString") then // Load function
b=c.Call(1,m)
end if
end if

This way your application will be loaded, you can call the function, but people who don't have the SpeechLib will also here it.

Call(paramcount as integer,data as memoryblock) as boolean

method, SoftDeclare Fr, 9. Aug 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: Calls a function.
Example:
dim c as softDeclare
dim m,p,b as memoryBlock
dim f as folderItem
dim path as string

f=applicationsFolder(-32766) // get a folder...
path=f.absolutePath

b=newmemoryBlock(1024)
b.long(0)=0 // make emptry C string

p=newmemoryBlock(lenb(path)+10)
p.cstring(0)=path

m=newmemoryBlock(12+10)
m.long(0)=p.address(0)
m.long(4)=b.address(0)
m.long(8)=b.size-1

if c.loadlibary("KERNEL32") then
if c.loadfunction("GetShortPathNameA") then

if c.Call(3,m) then
msgbox "Short path is: "+b.cstring(0)
else
msgbox "Failed to call function."
end if
else
msgbox "Loading of function "+c.FunctionName+" failed."
end if
else
msgbox "Loading of "+c.libname+" failed."
end if
Notes:
If paramtercount is 0, the memoryblock is ignored.
The size of the memoryblock must be minimum 4*paramcount.
Each parameter is set using m.long(n*4) where n=0 is the first parameter.
A parameter may be any integer value or an address of a memoryblock. The address can be read using memoryblock.address() which is part of the plugin. You can even use only one memoryblock for all 3 parameters in the example like this:

m=newmemoryBlock(2100)
m.cstring(1024)=path
m.long(0)=m.address(20)
m.long(4)=m.address(1024)
m.long(8)=1000

First 12 bytes for the parameter table, the next 1000 bytes for the result buffer and finally a thousand bytes for the input string.

Not tested for doubles!

FunctionFound as boolean

property, SoftDeclare Fr, 9. Aug 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: Was the function loaded?
Notes: Set by the LoadFunction function.

FunctionName as string

property, SoftDeclare Fr, 9. Aug 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: The name of the function to load.
Notes: Set by the LoadFunction function.

FunctionPointer as integer

property, SoftDeclare Fr, 9. Aug 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: The pointer of the function loaded.
Notes: Set by the LoadFunction function.

Liberror as string

property, SoftDeclare Fr, 9. Aug 2002
Mac OS Classic: Works. Mac OS Carbon: -> "". Windows: -> "".
Function: On Mac OS Classic an error message from loadlibrary.
Notes: Set by the LoadLibrary function.

Libfound as boolean

property, SoftDeclare Fr, 9. Aug 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: Was the library loaded?
Notes: Set by the LoadLibrary function.

Libhandle as integer

property, SoftDeclare Fr, 9. Aug 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: The handle of the library loaded.
Notes:
Set by the LoadLibrary function.
On Mac OS Classic a CFragConnectionID.
On Mac OS X a CFBundleRef.
On Windows a HINSTANCE.

Libname as string

property, SoftDeclare Fr, 9. Aug 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: The name of the library to load.
Notes: Set by the LoadLibrary function.

LoadFunction(funcname as string) as boolean

method, SoftDeclare Fr, 9. Aug 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: Loads a function from inside the library.

LoadLibary(libname as string) as boolean

method, SoftDeclare Fr, 9. Aug 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: Loads a library.
Notes:
On Mac OS X e.g. "Carbon.framework" or "System.framework".
On Mac OS Classic e.g. "InterfaceLib" or "SpeechLib".
On Mac OS Carbon inside Classic e.g. "CarbonLib".
On Windows e.g. "KERNEL32" or "USER32".

Result as integer

property, SoftDeclare Fr, 9. Aug 2002
Mac OS Classic: Works. Mac OS Carbon: Works. Windows: Works.
Function: The result of the call function.
Notes: Set by the Call function.

Contact

Written 2002 by Christian Schmitz. Feel free to ask or report mistakes to realbasic@macsw.de.
Thanks.

This resource fork intentionally left blank ˇˇ